package com.itheima.goods.mapper;

import com.github.pagehelper.Page;

import com.itheima.annotation.AutoFill;
import com.itheima.enumeration.OperationType;
import com.itheima.goods.dto.CategoryPageQueryDTO;
import com.itheima.goods.pojo.Category;
import com.itheima.goods.pojo.Dish;
import com.itheima.goods.pojo.Setmeal;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CategoryMapper {



 /**
     * 查询分类
     * @param categoryPageQueryDTO
     * @return
     */
    Page<Category> pageSelect(CategoryPageQueryDTO categoryPageQueryDTO);



   @AutoFill(value = OperationType.INSERT)
    void addCategory(Category category);


    @AutoFill(value = OperationType.UPDATE)
    void update(Category category);

    @Delete("delete from category where id=#{id}")
    void deleteById(Long id);

    @Select("select * from category where type=#{type}")
    List<Category> listByType(Integer type);

    @Select("select * from category where id=#{Id}")
    Category selectById(Long id);

    @Select("select * from dish where category_id=#{id}")
    List<Dish> listDishByType(Long id);
    @Select("select * from setmeal where category_id=#{id}")
    List<Setmeal> medallistByType(Long id);
    /**
     * 用户端条件查询分类
     * @param type
     * @return
     */
     @Select("select * from Category where type=#{type}")
     List<Category> selectByType(Long type);

     @Select("select * from category")
     List<Category> all();

}
